package cn.lanqiao.ui;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.JTextPane;
import javax.swing.border.EmptyBorder;
import javax.swing.ImageIcon;
import java.awt.Font;
import java.awt.SystemColor;

public class WordFrame extends JDialog {

	private static final long serialVersionUID = 1L;
	private final JPanel contentPanel = new JPanel();
	private JTextPane wordText;
	private JTable table;
	public static void main(String[] args) {
		try {
			WordFrame dialog = new WordFrame();
			dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
			dialog.setVisible(true);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public WordFrame(JTable table) {
		this();
		this.table = table;
		String word = table.getValueAt(MainFrame.i, 0).toString();
		wordText.setText(word);
	}
	
	public WordFrame() {
		setAlwaysOnTop(true);
		setResizable(false);
		setModal(true);
		setBounds(100, 100, 572, 332);
		getContentPane().setLayout(new BorderLayout());
		contentPanel.setBackground(Color.LIGHT_GRAY);
		contentPanel.setForeground(Color.DARK_GRAY);
		contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
		getContentPane().add(contentPanel, BorderLayout.CENTER);
		contentPanel.setLayout(null);
		
		JLabel lblWord = new JLabel("word");
		lblWord.setForeground(new Color(0, 191, 255));
		lblWord.setFont(new Font("方正舒体", Font.PLAIN, 36));
		lblWord.setBounds(245, 107, 86, 39);
		contentPanel.add(lblWord);
		
		wordText = new JTextPane();
		wordText.setBounds(206, 170, 164, 23);
		contentPanel.add(wordText);
		
		JButton button = new JButton("查看意思");
		button.setForeground(SystemColor.textHighlight);
		button.setBackground(SystemColor.activeCaption);
		button.setFont(new Font("方正舒体", Font.PLAIN, 16));
		button.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				TranslationFrame translationFrame = new TranslationFrame(table);
				WordFrame.this.dispose();
				translationFrame.setVisible(true);
			}
		});
		button.setBounds(237, 220, 103, 23);
		contentPanel.add(button);
		
		JLabel label_1 = new JLabel("");
		label_1.setIcon(new ImageIcon("photoes\\word.png"));
		label_1.setBounds(0, 0, 566, 303);
		contentPanel.add(label_1);
		
		this.setLocationRelativeTo(null);
	}
	
	
}
